package com.easyaccount.controller;

import com.easyaccount.bean.LoginUser;
import com.easyaccount.commons.CommonResp;
import com.easyaccount.service.UserProfileService;
import com.easyaccount.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/user/profile")
public class UserProfileController {
    private String prefix = "user/";

    @Resource
    private UserProfileService userProfileService;

    /**
     * 个人信息
     * @return
     */
    @GetMapping
    public String profile(){
        return prefix + "userInfo";
    }

    @RequestMapping("update")
    @ResponseBody
    public CommonResp<LoginUser> update(LoginUser loginUser, HttpServletRequest request){
        return userProfileService.updateUser(loginUser,request.getSession());
    }
}
